#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<math.h>
int pd(int n)
{
	int count=0;
	int a = n;
	while (a)
	{
		count++;
		a /= 10;
	}
	int sum = 0;
	while (n)
	{
		sum += pow(n % 10, count);
		n /= 10;
	}
	return sum;
}

int main()
{
	for (int i = 1; i < 100000; i++)
	{
		if (pd(i) == i)
			printf("%d ", i);
	}


	return 0;
}